package cn.web.management.web.servlet.inform.admin;

import cn.web.management.domain.Salary;
import cn.web.management.service.general.AdminUpdate;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "entrySalaryServlet", value = "/entrySalaryServlet")
public class entrySalaryServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    /**
     * @description: 录入员工工资
     * @paramName: [req, resp]
     * @paramType: [javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse]
     * @returnType: void
     */
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Salary salary = new Salary();
        salary.setEmployno(req.getParameter("employno"));
        salary.setPayoff_time(req.getParameter("payoff_time"));
        salary.setBase_salary(req.getParameter("base_salary"));
        salary.setWorking_time(req.getParameter("working_time"));
        salary.setBonus(req.getParameter("bonus"));
        salary.setSubsidies(req.getParameter("bonus"));
        salary.setOvertime_salary(req.getParameter("overtime_salary"));
        salary.setLeave_late(req.getParameter("leave_late"));
        salary.setTax(req.getParameter("tax"));

        AdminUpdate adminUpdate = new AdminUpdate();
        boolean b = adminUpdate.entrySalary(salary);
        resp.getWriter().write(b+"");
    }
}
